package com.jlt.service.account;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.jlt.dao.account.PostDao;
import com.jlt.entity.account.Post;

/**
 * 职位相关实体的管理类,.
 * 
 * @author zhoutao
 */
//Spring Bean的标识.
@Component
//默认将类中的所有函数纳入事务管理.
@Transactional
public class PostManager {

	private static Logger logger = LoggerFactory.getLogger(PostManager.class);

	private PostDao postDao;

	//-- Post Manager --//
	@Transactional(readOnly = true)
	public Post getPost(Long id) {
		return postDao.get(id);
	}
	
	/**
	 * 使用属性过滤条件查询用户.
	 */
	@Transactional(readOnly = true)
	public Page<Post> searchPost(final Page<Post> page, final List<PropertyFilter> filters) {
		return postDao.findPage(page, filters);
	}

	@Transactional(readOnly = true)
	public List<Post> getAllPost() {
		return postDao.getAll("id", true);
	}

	public void savePost(Post entity) {
		postDao.save(entity);
	}

	public void deletePost(Long id) {
		logger.info("del post success");
		postDao.delete(id);
	}
	
	@Autowired
	public void setPost(PostDao postDao) {
		this.postDao = postDao;
	}
}
